package com.ruoyi.web.controller.qsng;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.qsng.domain.TStudentCertificate;
import com.ruoyi.qsng.service.ITStudentCertificateService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生获奖Controller
 * 
 * @author gk
 * @date 2023-08-15
 */
@RestController
@RequestMapping("/system/certificate")
public class TStudentCertificateController extends BaseController
{
    @Autowired
    private ITStudentCertificateService tStudentCertificateService;

    /**
     * 查询学生获奖列表
     */
    @PreAuthorize("@ss.hasPermi('system:certificate:list')")
    @GetMapping("/list")
    public TableDataInfo list(TStudentCertificate tStudentCertificate)
    {
        startPage();
        List<TStudentCertificate> list = tStudentCertificateService.selectTStudentCertificateList(tStudentCertificate);
        return getDataTable(list);
    }

    /**
     * 导出学生获奖列表
     */
    @PreAuthorize("@ss.hasPermi('system:certificate:export')")
    @Log(title = "学生获奖", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TStudentCertificate tStudentCertificate)
    {
        List<TStudentCertificate> list = tStudentCertificateService.selectTStudentCertificateList(tStudentCertificate);
        ExcelUtil<TStudentCertificate> util = new ExcelUtil<TStudentCertificate>(TStudentCertificate.class);
        util.exportExcel(response, list, "学生获奖数据");
    }

    /**
     * 获取学生获奖详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:certificate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tStudentCertificateService.selectTStudentCertificateById(id));
    }

    /**
     * 新增学生获奖
     */
    @PreAuthorize("@ss.hasPermi('system:certificate:add')")
    @Log(title = "学生获奖", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TStudentCertificate tStudentCertificate)
    {
        return toAjax(tStudentCertificateService.insertTStudentCertificate(tStudentCertificate));
    }

    /**
     * 修改学生获奖
     */
    @PreAuthorize("@ss.hasPermi('system:certificate:edit')")
    @Log(title = "学生获奖", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TStudentCertificate tStudentCertificate)
    {
        return toAjax(tStudentCertificateService.updateTStudentCertificate(tStudentCertificate));
    }

    /**
     * 删除学生获奖
     */
    @PreAuthorize("@ss.hasPermi('system:certificate:remove')")
    @Log(title = "学生获奖", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tStudentCertificateService.deleteTStudentCertificateByIds(ids));
    }
}
